home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 May: Tool Chest / Dev.CD May 97 TC.toast / Tool Chest / QuickDraw / Virtual Sphere 1.0.1 / Virtual Sphere Sample Code 1.1 / Graphics3D.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-25  |  2.2 KB  |  70 lines  |  [TEXT/MPS ]

  1. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  2. /* Graphics3D.c
  3. /*
  4. /* 3D graphics and math routines
  5. /*
  6. /* Author: Michael Chen, Human Interface Group / ATG
  7. /* Copyright © 1991-1993 Apple Computer, Inc.  All rights reserved.
  8. /*
  9. /* Part of Virtual Sphere Sample Code Release v1.1
  10. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  11.  
  12. #ifndef    __GRAPHICS3D__
  13. #define __GRAPHICS3D__
  14.  
  15. #ifndef __GLOBALS__
  16. #include "Globals.h"
  17. #endif
  18.  
  19. #ifndef __GRAF3D__
  20. #include <Graf3D.h>
  21. #endif
  22.  
  23. #ifndef __MyMath__
  24. #include "MyMath.h"
  25. #endif
  26.  
  27. #define Integer    long
  28.  
  29. typedef struct {
  30.     Real    x;
  31.     Real    y;
  32.     Real    z;
  33. } CPoint3D;
  34.  
  35. typedef Real Matrix4D[4][4]; 
  36.  
  37. typedef struct { 
  38.     Integer     fVertexCount;            /* Number of vertices in this polygon */
  39.     Integer        fFirstVertexIndex;        /* Index into the fVertexIndices array */
  40.     Integer     fColorIndex;            /* Index into the fColor array */
  41. } NetPolygon;
  42.  
  43. typedef struct {
  44.     Integer        fPolygonCount;            /* Number of NetPolygons in this structure */
  45.     NetPolygon    *fPolys;                /* Array of NetPolygons */
  46.     Integer        fVertexCount;            /* Number of vertices in this structure */
  47.     Point3D        *fVertices;                /* Array of vertices */
  48.     Integer        *fVertexIndices;        /* Array of vertex indices */
  49.     RGBColor    *fColor;                 /* Array of RGBColors */
  50. } PolygonNetData;
  51.  
  52. pascal    OSErr    InitializeGraphics3D (void);
  53. pascal    void    FreeGraphics3D (void);
  54.  
  55. pascal    void    CopyMatrix (Matrix4D fromMatrix, Matrix4D toMatrix);
  56. pascal    void    CrossProduct3D (const CPoint3D *a, const CPoint3D *b, CPoint3D *aCrossB);
  57. pascal    Real    DotProduct3D (const CPoint3D *a, const CPoint3D *b);
  58. pascal    Real    Length3D (const CPoint3D *a);
  59. pascal    void    Matrix2XfMatrix (Matrix4D fromMatrix, XfMatrix toMatrix);
  60. pascal    void    MultiplyMatrix (Matrix4D a, Matrix4D b, Matrix4D aTimesB);
  61. pascal    void    Normalize3D (CPoint3D *v);
  62. pascal    void    OrthogonalizeRotationMatrix (Matrix4D matrix);
  63. pascal    void    SetRotationMatrix (Matrix4D rotationMatrix, const CPoint3D *op, const CPoint3D *oq);
  64. pascal    void    UnitCrossProduct3D (const CPoint3D *a, const CPoint3D *b, CPoint3D *aCrossB);
  65.  
  66. pascal    void    DrawPolyNet (const PolygonNetData *polyNet);
  67. pascal    void    PolyColor (const RGBColor *rGBColor);
  68.  
  69. #endif __GRAPHICS3D__
  70.